<template>
	<el-container>
		<el-main class='x-main-edit'>
			<el-form ref="form" :rules="form_rules" :model="form" size="mini" label-width="15%">
				<el-tabs type="border-card" v-model="page_tag">
					<!---->
					<!---->
					<el-tab-pane :label="page_info.title" name="1">
						<el-form-item label="名称" prop="cuser_name">
							<el-input :disabled="form.cuser_enable==1" v-model="form.cuser_name" class="x-input-60"></el-input>
						</el-form-item>
						<el-form-item label="openid">
							{{ form.cuser_openid }}
						</el-form-item>
						<el-form-item label="手机号">
							{{ form.cuser_phone }}
						</el-form-item>
						<el-form-item label="身份证" prop="cuser_idcard">
							<el-input :disabled="form.cuser_enable==1" v-model="form.cuser_idcard" class="x-input-60"></el-input>
						</el-form-item>
						<el-form-item label="身份证-正面">
							<CompImg :img_root="page_info.static_file_root" :img_val="form.cuser_idcard_pic1"></CompImg>
						</el-form-item>
						<el-form-item label="身份证-反面">
							<CompImg :img_root="page_info.static_file_root" :img_val="form.cuser_idcard_pic2"></CompImg>
						</el-form-item>
						<el-form-item label="驾驶证号" prop="cuser_car_no">
							<el-input :disabled="form.cuser_enable==1" v-model="form.cuser_car_no" class="x-input-60"></el-input>
						</el-form-item>
						<el-form-item label="驾驶证-正面">
							<CompImg :img_root="page_info.static_file_root" :img_val="form.cuser_car_no_pic"></CompImg>
						</el-form-item>
						<el-form-item label="驾驶证-正面">
							<CompImg :img_root="page_info.static_file_root" :img_val="form.cuser_car_no_pic1"></CompImg>
						</el-form-item>
						<el-form-item label="备注" prop="cuser_remak">
							<el-input v-model="form.cuser_remak" class="x-input-60"></el-input>
							<el-button type="success" @click="g_page.funcSave" size="mini">修改备注</el-button>
						</el-form-item>
						<el-form-item label="证件过期时间" prop="cuser_car_end_date">
							<el-date-picker
								:disabled="form.cuser_enable==1"
								value-format="yyyy-MM-dd"
								v-model="form.cuser_car_end_date"
								:picker-options="g_cc.picker_options"
								type="date">
							</el-date-picker>
							<div style="color:red;" v-if="form.card_expire">已过期</div>
						</el-form-item>
						<el-form-item label="紧急联系人">
							<div>{{ form.cuser_emergency_name }}</div>
							<div>{{ form.cuser_emergency_phone }}</div>
						</el-form-item>
						<el-form-item label="保证金">
							<b style="color:blue;">
								{{ form.ensure_price_left }}
							</b> /
							{{ form.cuser_ensure_price }}
						</el-form-item>
						<el-form-item label="审核状态">
							{{ form.enable }}
						</el-form-item>
						<el-form-item label="审核人" v-if="form.cuser_enable!=0">
							<div>{{ form.acc_name }}</div>
						</el-form-item>
						<el-form-item v-if="form.cuser_enable!=0" label="审核时间">
							{{ form.cuser_enable_date }}
						</el-form-item>
						<el-form-item label="审核原因" prop="cuser_enable_desc">
							<!--							<el-input :disabled="form.cuser_enable==1" v-model="form.cuser_enable_desc" class="x-input-60"></el-input>-->
							{{ form.cuser_enable_desc }}
						</el-form-item>
					</el-tab-pane>
					<!---->
					<!---->
					<el-tab-pane v-if="false" label="高级配置" name="2">
						<el-form-item label="用车限制" prop="cspu_only_plan">
							<el-radio-group v-model="form.cspu_only_plan">
								<el-radio :label="0">分时or套餐</el-radio>
								<el-radio :label="1">仅套餐</el-radio>
							</el-radio-group>
							<div class="x-alert">
								<span>仅套餐：只能购买套餐租车，不可使用分时租车</span><br/>
							</div>
						</el-form-item>
					</el-tab-pane>
					<!---->
					<!---->
				</el-tabs>
			</el-form>
			<!---->
			<!---->
			<!-- 按钮部分 -->
			<div class="save_wrap">
				<el-button @click="g_page.funcBack" size="mini">返回</el-button>
				<el-button size="mini" type="warning" icon="el-icon-edit-outline" @click="funcApply">审核</el-button>
				<!--				<el-checkbox v-if="page_info.is_admin_edit" style="margin-left: 10px;" label="保存后停留" v-model="checked"/>-->
			</div>
			<!---->
			<!---->
			<!-- 弹框 -->
			<el-dialog title="客户审核" :visible.sync="dialog_visible" width="70%">
				<el-form ref="form" :rules="form_dialog_rules" :model="form_dialog" size="mini" label-width="15%">
					<el-form-item label="审核描述">
						<el-input v-model="form_dialog.desc" class="x-input-60" placeholder="选填"/>
					</el-form-item>
					<el-form-item label="姓名" prop="cuser_name">
						{{ form.cuser_name }}
					</el-form-item>
					<el-form-item label="身份证" prop="cuser_idcard">
						{{ form.cuser_idcard }}
					</el-form-item>
					<el-form-item label="驾驶证号" prop="cuser_car_no">
						{{ form.cuser_car_no }}
					</el-form-item>
					<el-form-item label="证件过期时间">
						{{ form.cuser_car_end_date }}
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click="funcApplyApi(10)" size="mini">不通过</el-button>
					<el-button type="success" @click="funcApplyApi(1)" size="mini">通过</el-button>
				</div>
			</el-dialog>
			<!---->
			<!---->
			<!---->
		</el-main>
	</el-container>
</template>

<script>
	import {
		Message,
		MessageBox,
		Loading
	} from 'element-ui'

	export default {
		data() {
			let page_data = {}
			//
			page_data = this.g_cc.funcGetInitData(page_data)
			page_data.dialog_visible = false
			page_data.form_dialog = {}
			page_data.form_dialog_rules = {}
			//
			return page_data
		},
		mounted() {
			console.log('mounted')
			console.log(this.$route.query)

			this.g_page.funcSetVue(this)
			//
			this.g_page.funcSetApiUrlEdit('/xadmin/app_car/app_car__user__edit')
			this.g_page.funcSetApiUrlSave('/xadmin/app_car/app_car__user__edit/save')
			let page = this
			//验证
			this.form_rules = {
				// cuser_idcard: [{
				// 	required: true,
				// 	message: '请输入身份证',
				// 	trigger: 'blur'
				// }],
				// cuser_car_no: [{
				// 	required: true,
				// 	message: '请输入驾驶证号',
				// 	trigger: 'blur'
				// }]
			}

			let data = this.$route.query
			this.g_page.funcEdit(data)
		},
		methods: {
			////////////////////
			//审核
			funcApply() {
				this.dialog_visible = true
			},
			funcApplyApi(apply) {
				this.g_cc.func_axios({
					url: '/xadmin/app_car/app_car__user__edit/apply',
					data: {
						ids: this.form.id,
						apply: apply,
						apply_desc: this.form_dialog.desc,
						cuser_car_end_date: this.form.cuser_car_end_date,
						cuser_car_no: this.form.cuser_car_no,
						cuser_idcard: this.form.cuser_idcard,
						cuser_name: this.form.cuser_name
					},
					success: (res) => {
						//
						if (res.data.errcode == 0) {
							this.g_cc.func_alert('成功', 'success', () => {
								if (apply == 10) {
									this.g_page.funcReload()
								} else {
									this.g_page.funcBack()
								}
							})
						} else {
							this.g_cc.func_alert(res.data.errmsg, 'error')
						}
						this.dialog_visible = false
					}
				})
			},
			funcShowDialogAfter() {
				console.log('funcShowDialogAfter')
			},
			//保存之前
			funcSaveBefore(data) {
				console.log('funcSaveBefore', data)

				// data.abc_str_00 = this.g_page.funcImgArrToStr(data.abc_str_00_imgs)

				return data
			}
		}
	}
</script>
